﻿using System.Web.Mvc;
using System.Web.Routing;
using Omu.AwesomeDemo.Infra;
using Omu.Awesome.Mvc;

namespace Omu.AwesomeDemo.WebUI
{
    public class Bootstrapper
    {
        public static void Bootstrap()
        {
            AreaRegistration.RegisterAllAreas();
            RouteConfigurator.RegisterRoutes(RouteTable.Routes);
            ControllerBuilder.Current.DefaultNamespaces.Add("Omu.AwesomeDemo.WebUI.Controllers"); //this is because I have 2 Home Controllers in root and in area
            ControllerBuilder.Current.SetControllerFactory(new WindsorControllerFactory(IoC.Container));
            WindsorConfigurator.Configure();
            ModelMetadataProviders.Current = new AwesomeModelMetadataProvider();

            Settings.Confirm.NoText = "No way";
            Settings.PopupForm.OkText = "Submit";
            Settings.PopupForm.ClientSideValidation = true;
            Settings.Lookup.Interactive = true;
            Settings.Lookup.Fullscreen = true;
            Settings.Lookup.ChooseText = "Ok";
            Settings.GetText = Trans;
        }

        //for translation example look at http://prodinner.codeplex.com
        public static string Trans(string type, string key)
        {
            if (type == "Confirm" && key == "Title") return "please confirm";
            if (type == "PopupForm" && key == "Title") return "fill the form, hit ok";
            if (type == "Lookup" && key == "Title") return "select something";
            switch (key)
            {
                case "Choose": return "Ok";
                case "Cancel": return "Cancel";
                case "Yes": return "Yes";
                case "No": return "No";
                case "More": return "show more results";
            }
            return null;
        }
    }
}